const http = require("http");
const fs = require("fs");

http.createServer((req, res) => {
    if (req.url == "/xxx") {
        res.writeHead(200, { "Content-type": "text/html;charset=utf8" })
        fs.readFile("./demo.html", (err, data) => {
            res.end(data)
        })
    } else if (req.url == "/yyy") {
        res.writeHead(200, { "Content-type": "text/html;charset=utf8" })
        fs.readFile("./test.html", (err, data) => {
            res.end(data)
        })
    } else if (req.url == "/img") {
        res.writeHead(200, { "Content-type": "image/png;charset=utf8" })
        fs.readFile("./1.png", (err, data) => {
            res.end(data)
        })
    } else {
        res.writeHead(200, { "Content-type": "text/html;charset=utf8" })
        res.end("找不到页面")
    }
}).listen(3000)